#ifndef GAMECONTROL_H
#define GAMECONTROL_H

#include"widget.h"
#include<QObject>
#include"manblue.h"
#include"manred.h"
#include"player.h"
#include"diamond.h"
#include"gamedefine.h"

class GameControl : public QObject
{
    //单例
    GameControl(QWidget* parent = nullptr);
    static GameControl* instance;
public:

    //获取单例
    static GameControl* Instance()
    {
        if(instance == nullptr)
        {
            return instance = new GameControl(Widget::widget);
        }
        return instance;
    }
    //游戏初始化
    void GameInit();
    void LoadStartScene();//加载开始场景
    void LoadGameScene();//游戏场景加载

    //游戏逻辑定时器开启
    void GameStart();

    //游戏逻辑定时器关闭
    void GameOver();

    //倒计时示数
    static int num  ;

    //存形状
    void addPlatform(double x,double y,int width,int height);

    //容器
    QList<QRectF> platforms;//平台组合
    QList<int> mKeyList;//按键组合

    QList<Diamond*> mDiamondsBlue;//钻石列表
    QList<Diamond*>mDiamondsRed;

    QGraphicsScene& getGameScene();

protected:

    //游戏视图
    QGraphicsView mGameView;

    //场景
    QGraphicsScene mGameScene;
    QGraphicsScene mStartScene;
    QGraphicsScene mDeathScene;
    QGraphicsScene mSuccessScene;

    //元素
    QGraphicsPixmapItem mBackground;//背景
    QGraphicsPixmapItem mWaterRed;//红水
    QGraphicsPixmapItem mWaterBlue;//蓝水
    QGraphicsPixmapItem mWaterGreen;//绿水
    QGraphicsPixmapItem mStrategyUpdown;//机关横杠
    QGraphicsPixmapItem mDoorBlue;
    QGraphicsPixmapItem mDoorRed;

    Player* p1;
    ManBlue mManBlue;
    ManRed mManRed;

    //定时器
    QTimer* mPlayerMoveTimer;//人物移动
    QTimer* mJumpTimer;//跳跃定时器
    QTimer* mFormTimer;//平台定时器
    QTimer* mGameTimer;

    QLCDNumber* lcdnumber;
};



#endif // GAMECONTROL_H

